package com.zzw.spring;

import com.zzw.spring.component.MonsterService;
import com.zzw.spring.component.SmartAnimalable;
import com.zzw.spring.ioc.ZzwSpringApplicationContext;
import com.zzw.spring.ioc.ZzwSpringConfig;

public class AppMain {
    public static void main(String[] args) {
        //这里就是相当于创建了一个ioc容器，并且传入了一个配置类
        ZzwSpringApplicationContext zzwSpringApplicationContext =
                new ZzwSpringApplicationContext(ZzwSpringConfig.class);
//        Object monsterService = zzwSpringApplicationContext.getBean("monsterService");
//        Object monsterService2 = zzwSpringApplicationContext.getBean("monsterService");
//
//        System.out.println("monsterService=" + monsterService);
//        System.out.println("monsterService2=" + monsterService2);
//
//        Object monsterDao = zzwSpringApplicationContext.getBean("monsterDao");
//        Object monsterDao2 = zzwSpringApplicationContext.getBean("monsterDao");
//        System.out.println("monsterDao=" + monsterDao);
//        System.out.println("monsterDao2=" + monsterDao2);

        //测试依赖注入
//        MonsterService monsterService =
//                (MonsterService)zzwSpringApplicationContext.getBean("monsterService");
//        monsterService.m1();

        //测试AOP
        SmartAnimalable smartDog = (SmartAnimalable)zzwSpringApplicationContext.getBean("smartDog");
        //System.out.println("smartDog=" + smartDog.getClass());
        smartDog.getSum(10,2);
        smartDog.getSub(10,2);
        System.out.println("ok");
    }
}
